<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="p"></p>
<script>
window.onresize = function (){
    p.innerHTML =
        "宽:" + window.innerWidth +
        ", 高:" + window.innerHeight;
}
</script>
</body>
</html>